<template>
  <div class="bulletin">
    <el-form label-width="130px" @submit.native.prevent="Edit(id)">
      <el-form-item label="活动名称">
        <el-input v-model="info.title" :disabled="true"/>
      </el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="info.name" :disabled="true"/>
      </el-form-item>
      <el-form-item label="性别">
        <el-input v-model="info.sex" :disabled="true"/>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="info.phone" :disabled="true"/>
      </el-form-item>
      <el-form-item label="身份证号">
        <el-input v-model="info.id_card" :disabled="true"/>
      </el-form-item>
      <el-form-item label="审核">
        <el-radio-group v-model="info.audit_status" >
          <el-radio :label="0">待审核</el-radio>
          <el-radio :label="1">审核通过</el-radio>
          <el-radio :label="2">审核拒绝</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" native-type="submit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import SingleImage from '@/components/Upload/SingleImage'
import Tinymce from '@/components/Tinymce'
import { parseTime } from '@/utils/index'
export default {
  components: {
    Tinymce,
    SingleImage
  },
  data() {
    return {
      id: this.$route.params.id,
      info: {},
      audit_status: 0,
      created_at: parseTime(new Date().getTime())
    }
  },
  mounted() {
    this.GetInfoById(this.id)
  },
  methods: {
    GetInfoById(id) {
      this.$http.get('activity_forms/' + id).then(response => {
        console.log(response)
        this.info = response.resource.info
        this.audit_status = this.info.audit_status
      })
    },
    Edit(id) {
      // this.info.zh_title || this.$error('请填写中文标题')
      const params = {
        activity_id: this.info.activity_id,
        name: this.info.name,
        sex: this.info.sex,
        phone: this.info.phone,
        id_card: this.info.id_card,
        created_at: this.info.created_at,
        audit_status: this.info.audit_status
      }
      this.$http.patch('activity_forms/' + id, params).then(response => {
        this.$success('操作成功')
        const page = this.$route.query.page || 1; // 默认到第一页
        this.$router.push({ path: '/activities/activity-forms', query: { page } })
      })
    }
  }
}
</script>

<style>
.bulletin .el-progress-circle {
  background: #fff;
}
.avatar-uploader {
  position: relative;
}
.avatar-uploader .percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  max-width: 500px;
  display: block;
}
</style>
